<template>
	<view>
		<home v-if="currentTab == 0" :item-ids-arr="itemIdsArr"></home>
		<viewSonic v-if="currentTab == 1" ></viewSonic>
		<nearby v-if="currentTab == 3"></nearby>
		<my v-if="currentTab == 4"></my>
		<CustomTabBar @tab-change="getTabChange"></CustomTabBar>
		<!-- 页面内容 -->
	</view>
</template>

<script setup>
	import CustomTabBar from '@/components/CustomTabBar.vue';
	import home from '@/pages/home/home.vue';
	import viewSonic from '@/pages/viewSonic/viewSonic.vue';
	import nearby from '../nearby/nearby.vue';
	import my from '../my/my.vue';
	import {
		onLoad
	} from '@dcloudio/uni-app';
	import {
		reactive,
		toRefs,ref 
	} from 'vue';
	const itemIdsArr = ref([]);

	const state = reactive({
		currentTab: 0,
	});
	const {
		currentTab
	} = toRefs(state);
	const getTabChange = (active) => {
		currentTab.value = active;
	}
	onLoad((options) => {
		if (options.itemIdsStr) {
			// 将"123,456"拆分为["123","456"]
			itemIdsArr.value = options.itemIdsStr.split(',').filter(id => id);
			// console.log('itemIdsArr.value',itemIdsArr.value);
		}
	})
</script>